package com.zuo.seckilldemo.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result <T>{
    private int code;
    private String msg;
    private T data;


    Result(T data){
        this.data = data;
    }
    Result(CodeMsg codeMsg) {
        if(codeMsg != null) {
            this.code = codeMsg.getCode();
            this.msg = codeMsg.getMsg();
        }
    }

    public static <T> Result<T> success(T data){
        return new Result<>(data);
    }
    public static <T> Result<T> success(int code, String msg,T data){
        return new Result<>(code,msg,data);
    }
    public static <T> Result<T> error(CodeMsg msg){
        return new Result<>(msg);
    }

    
}
